<template>
  <div class="header">
    <div class="title">TodoList</div>
    <input type="text" v-model="title" @keyup.enter="submitTitle">
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
  name: 'header',
  setup (props, context) {
    const title = ref('')
    const submitTitle = () => {
      context.emit('add-item', { title })
      title.value = ''
    }
    return {
      title,
      submitTitle
    }
  }
})
</script>

<style scoped>
  .header {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
    background-color: #000000;
  }
  .title {
    color: #ffffff;
    font-size: 28px;
    font-weight: bold;
  }
  .header input {
    width: 300px;
    height: 25px;
    border-radius: 5px;
    margin-left: 100px;
    padding-left: 10px;
    border: none;
    outline: none;
  }
  .header input:hover {
    border: none;
  }
</style>
